# -*- coding: utf-8 -*-

import json

class Repository(object):
    def __init__(self, client, item):
        self.client = client
        self.id = item['repository_id']
        self.uuid = item['repository_uuid']
        self.name = item['repository_name']
        self.sshUrl = item['ssh_url']
        self.httpsUrl = item['https_url']
        self.groupName = item['group_name']
        self.webUrl = item['web_url']
        self.visibilityLevel = item['visibility_level']
        self.createdAt = item['created_at']
        self.updatedAt = item['updated_at']
        self.projectUuid = item['project_uuid']
        self.projectIsDeleted = item['project_is_deleted']
    
    @staticmethod
    def find_by_uuid(client, uuid):
        url = '/codehub/v2/repositories/'+uuid
        response = client.get_data(url)
        item = json.loads(response.text)['result']
        return Repository(client, item)